class test5:  # 定义方法类
    @staticmethod  # 采用静态方法，方便通过类直接调用
    def add(v, ThreeDimensionalVector):
        ax = v.x+ThreeDimensionalVector.x
        ay = v.y+ThreeDimensionalVector.y
        az = v.z+ThreeDimensionalVector.z
        Vector3 = (ax, ay, az)  # 将结果转化位元组，方便显示。 因为是元组，所以这个值只能赋值一次
        print("尊敬的主人，按照您的要求，向量"+n1.split(" ")
              [0]+"+" + n1.split(" ")[1] + "的计算结果为：Vector3", Vector3)

    @staticmethod
    def sub(v, ThreeDimensionalVector):
        sx = v.x-ThreeDimensionalVector.x
        sy = v.y-ThreeDimensionalVector.y
        sz = v.z-ThreeDimensionalVector.z
        Vector3 = (sx, sy, sz)
        print("尊敬的主人，按照您的要求，向量"+n1.split(" ")
              [0]+"-" + n1.split(" ")[1] + "的计算结果为：", Vector3)

    @staticmethod
    def mul(v, a):
        mx = (v.x)*a
        my = (v.y)*a
        mz = (v.z)*a
        Vector3 = (mx, my, mz)
        print("尊敬的主人，按照您的要求，向量"+n1.split(" ")
              [0]+"*" + n1.split(" ")[1] + "的计算结果为：", Vector3)

    @staticmethod
    def div(ThreeDimensionalVector, b):
        dx = ThreeDimensionalVector.x/b
        dy = ThreeDimensionalVector.y/b
        dz = ThreeDimensionalVector.z/b
        Vector3 = (dx, dy, dz)
        print("尊敬的主人，按照您的要求，向量"+n1.split(" ")
              [0]+"/" + n1.split(" ")[1] + "的计算结果为：", Vector3)

    @staticmethod
    def lengtn(ThreeDimensionalVector):
        return pow(pow(ThreeDimensionalVector.x, 2)+pow(ThreeDimensionalVector.y, 2)+pow(ThreeDimensionalVector.z, 2), 0.5)


class ThreeDimensionalVector:  # 定义三维坐标类
    def __init__(self, x, y, z):  # 定义构造方法
        self.x = x
        self.y = y
        self.z = z


# 对象字典
d = {}  # 声明字典
d['v1'] = ThreeDimensionalVector(5, 6, 7)  # 实例化对象并放进字典里
d['v2'] = ThreeDimensionalVector(3, 4, 5)  # 实例化对象并放进字典里
print("17级青软2班 李翔宇 17114120208")
print("====================================")
print("欢迎使用三维运算系统")
print("1.计算v1 + v2")
print('2.计算v1 – v2')
print('3.计算v与标量相乘')
print('4.计算v与标量相除')
print('----------------------------------------------------------')
n = int(input('请输入对应的功能序号：'))
if (n == 1):
    # 键盘输入转换为列表
    n1 = input('请输入三维向量对象：')
    test5.add(d[n1.split(" ")[0]], d[n1.split(" ")[1]])  # 使用split()函数进行分割
elif (n == 2):
    n1 = input('请输入三维向量对象：')
    test5.sub(d[n1.split(" ")[0]], d[n1.split(" ")[1]])
elif (n == 3):
    n1 = input('请输入三维向量对象和标量：')
    test5.mul(d[n1.split(" ")[0]], int(n1.split(" ")[1]))  # 将字符串类型强制转化成int类型
elif (n == 4):
    n1 = input('请输入三维向量对象和标量：')
    test5.div(d[n1.split(" ")[0]], int(n1.split(" ")[1]))
else:
    print("请输入正确的选项")
print(n1.split(" ")[0]+"的模长为：", test5.lengtn(d[n1.split(" ")[0]]))
print("欢迎再次使用本系统，主人再见！")
print("====================================")
